<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker,autocomplete"></t:base>

<div class="easyui-layout" fit="true">
  <div region="center" style="padding:1px;">
  <t:datagrid name="tasksList" title="任务单" actionUrl="tasksController.do?datagrid" idField="fid" fit="true" queryMode="group" rowStyler="setMyColor">
   <t:dgCol title="编号" field="id" hidden="true"></t:dgCol>
   <t:dgCol title="fid" field="fid" hidden="true"></t:dgCol>
   <t:dgCol title="首道工序id" field="fNextReportId" hidden="true"></t:dgCol>
   <t:dgCol title="状态" field="fstate" query="true" dictionary="rwdstate"  style="setColor()"></t:dgCol>
   <t:dgCol title="本厂批号" field="fbcph" query="true" autocomplete="true"></t:dgCol>
   <t:dgCol title="物料名称" field="fwlname"  query="true" ></t:dgCol>
   <t:dgCol title="原料供货商" field="fylghs" ></t:dgCol>
   <t:dgCol title="原厂炉号" field="fyclh" ></t:dgCol>
   <t:dgCol title="规格型号" field="ftype" hidden="true"></t:dgCol>
   <t:dgCol title="厚度" field="fthick" ></t:dgCol>
   <t:dgCol title="宽度" field="fwidth" ></t:dgCol>
   <t:dgCol title="重量" field="fweight" ></t:dgCol>
   <t:dgCol title="生产车间" field="fworkshop" dictionary="workshop" hidden="false"></t:dgCol>
   
   <t:dgCol title="成材率" field="frate"  hidden="false"></t:dgCol>
   <t:dgCol title="制单人" field="createBy" ></t:dgCol>
   <t:dgCol title="制单日期" field="createDate" formatter="yyyy-MM-dd" query="true" queryMode="group"></t:dgCol>
    <t:dgCol title="修改日期" field="updateDate" formatter="yyyy-MM-dd hh:mm:ss" hidden="false"></t:dgCol>
   <t:dgToolBar title="录入" icon="icon-add" url="tasksController.do?edit" funname="add"></t:dgToolBar>
   <t:dgToolBar title="反下单" icon="icon-undo" url="tasksController.do?returnPlace" funname="returnPlace" operationCode="returnPlace"></t:dgToolBar>
   <t:dgToolBar title="查看" icon="icon-search" url="tasksController.do?addorupdate" funname="showProcesss"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>
 
  <script>
  
  /**
	 * 查看详细事件打开窗口
	 * @param title 查看框标题
	 * @param addurl//目标页面地址
	 * @param id//主键字段
	 */
	function showProcesss(title,url, id,width,height) {
		var rowsData = $('#'+id).datagrid('getSelections');
	//	if (rowData.id == '') {
	//		tip('请选择查看项目');
	//		return;
	//	}
		
		if (!rowsData || rowsData.length == 0) {
			tip('请选择查看项目');
			return;
		}
		if (rowsData.length > 1) {
			tip('请选择一条记录再查看');
			return;
		}
	    url += '&load=detail&id='+rowsData[0].fid+'&fbcph='+rowsData[0].fbcph;
		createdetailwindow(title,url,'100%','100%');
	}


   function setMyColor(index,row){
 	   console.log(row);
 		if(row.fstate==1){
 			return "color:green;";
 		}
 		if(row.fstate==2){
 			return "color:red;";
 		}
 		return "";
 	}
	
 	function setColor(value,rec,index){
 		
 		if(value==1){
 			return "color:green;";
 		}
 		if(value==2){
 			return "color:red;";
 		}
 		return "";
 	}
 	
 	 	function setColor2(value,rec,index){
 		
 		return "color:green";
 	}
 		$(document).ready(function(){
		$("input[name='createDate_begin']").attr("class","easyui-datebox");
		$("input[name='createDate_end']").attr("class","easyui-datebox");
	});
 	
 </script>